package com.cykj.pos.controller.api;

import com.cykj.common.core.domain.AjaxResult;
import com.cykj.pos.domain.ResetQueueEntity;
import com.cykj.pos.service.ResetQueueService;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * @author SunJinDuo
 * @date 2022/7/25
 */
@RestController
@RequestMapping("/reset/queue")
@Api(tags = "重置")
public class ResetQueueController {

    private static final Logger logger = LoggerFactory.getLogger(ResetQueueController.class);

    @Autowired
    private ResetQueueService resetQueueService;

    @GetMapping("/getList")
    public AjaxResult getList(ResetQueueEntity resetQueueEntity) throws ParseException {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String startTime = df.format(System.currentTimeMillis());
        logger.info("<<<<<--- 开始时间：" + startTime + "。开启流水统计接口定时任务 --->>>>> -");
        String merchIds="13,15,16,17,18,20,21,22,23,24,27,28,29,30,31,32,33,34,37,38,39,40,41,42,43,44,45,46,51,53,54,55,56,57,58,60,61,62,64,66,69,70,71,73,74,76,77,78,79,80,82,83,84,85,86,87,89,90,91,92,93,94,95,96,97,101,104,106,107,108,109,111,112,114,115,116,117,119,121,122,124,125,126,130,131,133,135,138,139,141,142,144,145,149,151,152,156,158,164,166,167,168,169,171,172,173,177,179,180,181,185,186,189,190,191,192,193,194,196,197,198,200,203,204,205,206,207,208,211,212,215,216,218,227,228,229,230,235,236,237,240,241,242,243,244,248,253,256,259,260,262,263,268,270,271,272,273,275,279,282,285,288,289,290,294,295,299,302,304,305,309,312,314,315,317,319,323,326,327,332,333,334,336,338,339,340,341,344,345,346,349,350,352,523,524,525,526,527,530,531,533,536,537,540,541,543,544,547,548,550,552,553,560,561,563,565,566,567,570,572,574,575,579,580,581,582,584,585,586,587,591,595,598,599,600,602,604,606,607,608,609,610,613,615,619,620,621,623,624,625,627,628,630,632,634,635,636,637,639,640,641,642,644,645,648,652,654,656,657,658,659,660,661,662,663,665,666,668,669,671,672,673,675,679,682,686,688,689,694,695,696,697,698,701,702,704,705,706,707,708,710,711,712,714,715,716,717,718,719,720,722,723,724,725,726,727,733,735,737,739,740,742,743,745,747,748,750,752,753,754,755,756,757,758,760,761,764,770,771,772,773,774,778,779,780,781,782,785,787,790,792,794,797,798,799,800,802,803,804,805,806,807,808,809,812,813,814,815,816,817,818,820,822,823,824,825,827,828,829,831,832,833,834,841,842,843,846,849,853,856,857,858,860,861,865,866,867,868,869,871,872,874,875,879,880,882,886,887,888,889,890,892,895,899,905,907,916,921,927,932,933,940,947,962,968,972,975,981,983,984,987,990,1000,1006,1014,1015,1020,1022,1025,1027,1031,1033,1035,1039,1043,1045,1048,1049,1050,1051,1054,1055,1057,1062,1063,1069,1074,1075,1076,1077,1079,1081,1082,1083,1085,1086,1090,1093,1100,1102,1104,1105,1108,1112,1113,1116,1121,1122,1123,1125,1126,1127,1128,1130,1131,1133,1134,1135,1136,1137,1138,1140,1142,1144,1145,1146,1147,1153,1156,1158,1160,1163,1164,1165,1167,1171,1174,1175,1178,1179,1182,1185,1189,1192,1196,1199,1200,1201,1209,1213,1216,1217,1219,1221,1223,1224,1225,1226,1227,1228,1229,1230,1236,1238,1239,1241,1242,1243,1246,1247,1248,1249,1253,1254,1255,1257,1260,1261,1264,1265,1266,1267,1268,1271,1272,1273,1274,1275,1276,1277,1278,1720,1721,1722,1724,1727,1728,1729,1733,1736,1737,1738,1740,1742,1744,1745,1746,1747,1748,1757,1760,1762,1765,1767,1770,1771,1774,1775,1789,1791,1796,1803,1806,1834,1836,1837,1838,1843,1844,1847,1848,1851,1852,1853,1854,1859,1863,1867,1869,1873,1874,1875,1878,1879,1880,1881,1882,1884,1886,1887,1889,1891,2003,2004,2005,2006,2012,2018,2022,2023,2024,2026,2027,2030,2032,2034,2040,2041,2042,2044,2049,2051,2053,2054,2056,2058,2059,2060,2062,2064,2065,2069,2075,2086,2088,2091,2092,2093,2094,2095,2098,2099,2106,2107,2108,2109,2110,2113,2115,2117,2118,2120,2122,2123,2124,2125,2126,2127,2129,2131,2139,2140,2141,2142,2143,2144,2145,2148,2149,2150,2151,2152,2153,2154,2158,2160,2162,2164,2166,2167,2172,2174,2187,2191,2198,2201,2202,2204,2208,2210,2216,2217,2219,2223,2224,2226,2227,2234,2237,2240,2244,2253";
//        String merchIds="1889";
        for (String merchId:merchIds.split(",")){
            resetQueueEntity.setMerchId(Long.parseLong(merchId));
            resetQueueEntity.setDateTime(df.parse("2023-03-01"));
            resetQueueService.getList(resetQueueEntity);
            resetQueueEntity.setDateTime(df.parse("2023-03-02"));
            resetQueueService.getList(resetQueueEntity);
        }
        // TODO 测试id
//        resetQueueEntity.setMerchId(1519L);
        return AjaxResult.success();
    }
    @GetMapping("/getLists")
    public AjaxResult getList() throws ParseException {
        ResetQueueEntity resetQueueEntity=new ResetQueueEntity();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String startTime = df.format(System.currentTimeMillis());
        logger.info("<<<<<--- 开始时间：" + startTime + "。开启流水统计接口定时任务 --->>>>> -");
//        String merchIds="13,15,16,17,18,20,21,22,23,24,27,28,29,30,31,32,33,34,37,38,39,40,41,42,43,44,45,46,51,53,54,55,56,57,58,60,61,62,64,66,69,70,71,73,74,76,77,78,79,80,82,83,84,85,86,87,89,90,91,92,93,94,95,96,97,101,104,106,107,108,109,111,112,114,115,116,117,119,121,122,124,125,126,130,131,133,135,138,139,141,142,144,145,149,151,152,156,158,164,166,167,168,169,171,172,173,177,179,180,181,185,186,189,190,191,192,193,194,196,197,198,200,203,204,205,206,207,208,211,212,215,216,218,227,228,229,230,235,236,237,240,241,242,243,244,248,253,256,259,260,262,263,268,270,271,272,273,275,279,282,285,288,289,290,294,295,299,302,304,305,309,312,314,315,317,319,323,326,327,332,333,334,336,338,339,340,341,344,345,346,349,350,352,523,524,525,526,527,530,531,533,536,537,540,541,543,544,547,548,550,552,553,560,561,563,565,566,567,570,572,574,575,579,580,581,582,584,585,586,587,591,595,598,599,600,602,604,606,607,608,609,610,613,615,619,620,621,623,624,625,627,628,630,632,634,635,636,637,639,640,641,642,644,645,648,652,654,656,657,658,659,660,661,662,663,665,666,668,669,671,672,673,675,679,682,686,688,689,694,695,696,697,698,701,702,704,705,706,707,708,710,711,712,714,715,716,717,718,719,720,722,723,724,725,726,727,733,735,737,739,740,742,743,745,747,748,750,752,753,754,755,756,757,758,760,761,764,770,771,772,773,774,778,779,780,781,782,785,787,790,792,794,797,798,799,800,802,803,804,805,806,807,808,809,812,813,814,815,816,817,818,820,822,823,824,825,827,828,829,831,832,833,834,841,842,843,846,849,853,856,857,858,860,861,865,866,867,868,869,871,872,874,875,879,880,882,886,887,888,889,890,892,895,899,905,907,916,921,927,932,933,940,947,962,968,972,975,981,983,984,987,990,1000,1006,1014,1015,1020,1022,1025,1027,1031,1033,1035,1039,1043,1045,1048,1049,1050,1051,1054,1055,1057,1062,1063,1069,1074,1075,1076,1077,1079,1081,1082,1083,1085,1086,1090,1093,1100,1102,1104,1105,1108,1112,1113,1116,1121,1122,1123,1125,1126,1127,1128,1130,1131,1133,1134,1135,1136,1137,1138,1140,1142,1144,1145,1146,1147,1153,1156,1158,1160,1163,1164,1165,1167,1171,1174,1175,1178,1179,1182,1185,1189,1192,1196,1199,1200,1201,1209,1213,1216,1217,1219,1221,1223,1224,1225,1226,1227,1228,1229,1230,1236,1238,1239,1241,1242,1243,1246,1247,1248,1249,1253,1254,1255,1257,1260,1261,1264,1265,1266,1267,1268,1271,1272,1273,1274,1275,1276,1277,1278,1720,1721,1722,1724,1727,1728,1729,1733,1736,1737,1738,1740,1742,1744,1745,1746,1747,1748,1757,1760,1762,1765,1767,1770,1771,1774,1775,1789,1791,1796,1803,1806,1834,1836,1837,1838,1843,1844,1847,1848,1851,1852,1853,1854,1859,1863,1867,1869,1873,1874,1875,1878,1879,1880,1881,1882,1884,1886,1887,1889,1891,2003,2004,2005,2006,2012,2018,2022,2023,2024,2026,2027,2030,2032,2034,2040,2041,2042,2044,2049,2051,2053,2054,2056,2058,2059,2060,2062,2064,2065,2069,2075,2086,2088,2091,2092,2093,2094,2095,2098,2099,2106,2107,2108,2109,2110,2113,2115,2117,2118,2120,2122,2123,2124,2125,2126,2127,2129,2131,2139,2140,2141,2142,2143,2144,2145,2148,2149,2150,2151,2152,2153,2154,2158,2160,2162,2164,2166,2167,2172,2174,2187,2191,2198,2201,2202,2204,2208,2210,2216,2217,2219,2223,2224,2226,2227,2234,2237,2240,2244,2253";
//        String merchIds="1889";
        List<Long> merchIds=resetQueueService.selectMerchIds();
        for (Long merchId:merchIds){
            resetQueueEntity.setMerchId(merchId);
            resetQueueEntity.setDateTime(df.parse("2023-03-01"));
            resetQueueService.getList(resetQueueEntity);
            resetQueueEntity.setDateTime(df.parse("2023-03-02"));
            resetQueueService.getList(resetQueueEntity);
        }
        // TODO 测试id
//        resetQueueEntity.setMerchId(1519L);
        return AjaxResult.success();
    }


}
